import Vue from 'vue'
import Router from 'vue-router'
import _import from '@/router/_import'
import Layout from '@/views/layout/layout'

Vue.use(Router)


export const page401 = {
    path: '/401',
    name: '401-权限不足',
    component: _import('error_page/page-404'),
    hidden: true
};


export const page404 = {
    path: '/*',
    name: '404-页面不存在',
    component: _import('error_page/page-404'),
    hidden: true
};

export const page500 = {
    path: '/500',
    name: '500-服务端错误',
    component: _import('error_page/page-500'),
    hidden: true
};

export const loginRouter = {
    path: '/login',
    name: 'Login - 登录',
    component: _import('login/Index'),
    hidden: true
};

export const indexRouter = {
    path: '/',
    redirect: '/dashboard/index',
    hidden: true
}

export const dashboardRouter = {
    path: '/dashboard',
    component: Layout,
    noDropDown: true,
    children: [
        { path: 'index', name: '控制台', icon: 'el-icon-mars-dashboard1', component: _import('dashboard/Index') }
    ]
};

export const profileRouter = {
    path: '/profile',
    component: Layout,
    hidden: true,
    children: [
        { path: 'profile', name: '个人中心', component: _import('profile/Index') },
        { path: 'message', name: '消息中心', component: _import('profile/Message') }
    ]
};

export const asyncAppRouter = [
    {
        path: '/car',
        name: '车况管理',
        component: Layout,
        redirect: 'noredirect',
        icon: 'el-icon-mars-users',
        children: [
            {path: 'harm', name: '车辆新伤', icon:'el-icon-menu', component: _import('tukuan/car/Harm')},
            {path: 'harm-detail/:carId/:isHarm/:carnum', name: '车辆新伤详情', icon:'el-icon-menu', component: _import('tukuan/car/HarmDetail'), hidden: true},
            {path: 'state', name: '车况记录', icon:'el-icon-menu', component: _import('tukuan/car/State')},
            {path: 'state-detail/:carId/:isHarm/:carnum', name: '车况记录详情', icon:'el-icon-menu', component: _import('tukuan/car/StateDetail'), hidden: true},
            {path: 'check', name: '车辆检查', icon:'el-icon-menu', component: _import('tukuan/car/Check')},
            {path: 'check-detail/:carId/:carnum', name: '车辆检查详情', icon:'el-icon-menu', component: _import('tukuan/car/CheckDetail'), hidden: true},
            {path: 'dq-check', name: '地勤检查', icon:'el-icon-menu', component: _import('tukuan/car/DQCheck')},
            {path: 'dq-check-detail/:userId/:realname', name: '地勤检查详情', icon:'el-icon-menu', component: _import('tukuan/car/DQCheckDetail'), hidden: true},
            {path: 'manager', name: '车辆管理', icon:'el-icon-menu', component: _import('tukuan/car/Manager')},
            {path: 'repair', name: '车辆保养', icon:'el-icon-menu', component: _import('tukuan/car/Repair')},
            {path: 'repair-log/:car_repair_id/:car_num', name: '车辆保养日志', icon:'el-icon-menu', component: _import('tukuan/car/RepairLog'), hidden: true},
            {path: 'user', name: '地勤用户', icon:'el-icon-menu', component: _import('tukuan/car/User')}
        ]
    },
    {
        path: '/credit',
        name: '信用积分管理',
        component: Layout,
        redirect: 'noredirect',
        icon: 'el-icon-mars-users',
        children: [
            {path: 'credit-mgr', name: '信用管理', icon: 'el-icon-menu', component: _import('tukuan/credit/CreditMgr')}
        ]
    },
    {
        path: '/report',
        name: '数据分析',
        component: Layout,
        redirect: 'noredirect',
        icon: 'el-icon-mars-users',
        children: [
            {path: 'report-month-user-money', name: '赔偿金额汇总', icon: 'el-icon-menu', component: _import('tukuan/report/ReportUserMonthTotalMoney')},
            {path: 'report-month-user-tc', name: '地勤提成汇总', icon: 'el-icon-menu', component: _import('tukuan/report/ReportUserMonthTotalTc')},
            {path: 'report-car-injure-total', name: '车辆损伤汇总', icon: 'el-icon-menu', component: _import('tukuan/report/ReportCarInjureMonthTotal')},
            {path: 'report-user-check-total', name: '车辆检查汇总', icon: 'el-icon-menu', component: _import('tukuan/report/ReportUserMonthCheckTotal')}
        ]
    },
    {
        path: '/upms',
        name: '授权中心',
        component: Layout,
        redirect: 'noredirect',
        icon: 'el-icon-mars-app',
        children: [
            {path: 'app', name: '应用管理', icon:'el-icon-mars-bell', component: _import('upms/App')},
            {path: 'menu', name: '菜单管理', icon:'el-icon-mars-bell', component: _import('upms/Menu')},
            {path: 'permission', name: '权限管理', icon:'el-icon-mars-bell', component: _import('upms/Permission')},
            {path: 'organization', name: '组织管理', icon:'el-icon-mars-bell', component: _import('upms/Organization')},
            {path: 'user', name: '用户管理', icon:'el-icon-mars-bell', component: _import('upms/User')},
            {
                path: 'role',
                name: '角色管理',
                icon:'el-icon-mars-bell',
                component: _import('upms/Role'),
                redirect: '/upms/role/index',
                noDropDown: true,
                children: [
                    {path: 'index', name: '角色查询', component: _import('upms/role/Index')},
                    {
                        path: 'apply-permission/:roleId',
                        name: '分配权限',
                        component: _import('upms/role/ApplyPermission'),
                        props: {roleId: ''}
                    },
                    {
                        path: 'userlist/:roleId',
                        name: '角色用户列表',
                        component: _import('upms/role/UserList'),
                        props: {roleId: ''}
                    }
                ]
            },
            {path: 'group', name: '用户组管理', icon:'el-icon-mars-bell', component: _import('upms/Group')},
            {path: 'group_user_list/:groupId', name: '组用户列表', icon:'el-icon-mars-users', component: _import('upms/GroupUserList'), hidden: true},

        ]
    },
    {
        path: '/system',
        name: '系统管理',
        component: Layout,
        redirect: 'noredirect',
        icon: 'el-icon-mars-system1',
        children: [
            {path: 'session', name: '会话管理', icon:'el-icon-mars-huihuafuwuqi', component: _import('system/Session')},
            {
                path: 'log',
                component: _import('system/Log'),
                name: '日志管理',
                redirect: '/system/log/login',
                noDropDown: true,
                icon: 'el-icon-mars-log',
                children: [
                    {path: 'login', name: '登陆日志', component: _import('system/log/Login')},
                    {path: 'operate', name: '操作日志', component: _import('system/log/Operate')},
                    {path: 'error', name: '错误日志', component: _import('system/log/Error')}
                ]
            }

        ]
    },
    page404
]

/**
 * 404路由必须放到路由最后
 * hidden: true
 * noDropDown: true,
 * @type {[null,null,null,null,null,null]}
 */
export const constantRouters = [
    loginRouter,
    indexRouter,
    dashboardRouter,
    profileRouter,
    page500,
    page401
]

export default new Router({
    routes: constantRouters
})